﻿using System.Collections.Generic;
using Fuse8.ContentManagementFramework.BizFacade;
using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Web.MvcPowered;
using Fuse8.ContentManagementFramework.Web.MvcPowered.Components.Models;

namespace Fuse8.ContentManagementFramework.Web.Etc.PagePresent
{
    /// <summary>
    /// Default page present strategy
    /// </summary>
    public class DefaultPagePresentStrategy : IPagePresentStrategy
    {
        protected CmsPage PageToPresent { get; private set; }  

        /// <summary>
        /// Inits startegy
        /// </summary>
        /// <param name="page">CmsPage to present</param>
        public virtual void Init(CmsPage page)
        {
            PageToPresent = page;
        }

        /// <summary>
        /// Gets list (tree) of items that present page in navigation control
        /// </summary>
        /// <returns></returns>
        public virtual IEnumerable<CmsPageComponentItemForNavigation> GetNavigationItems()
        {
            yield return new CmsPageComponentItemForNavigation(PageToPresent);
        }

        /// <summary>
        /// Gets list of items that present page in breadcrumb control
        /// </summary>
        /// <returns></returns>
        public virtual IEnumerable<CmsPageComponentItem> GetBreadcrumbItems()
        {
            yield return new CmsPageComponentItem(PageToPresent);
        }

        /// <summary>
        /// Gets page meta keyword
        /// </summary>
        /// <returns></returns>
        public virtual string GetPageMetaKeywords()
        {
            return PageToPresent.PageKeywords;
        }

        /// <summary>
        /// Gets page meta title
        /// </summary>
        /// <returns></returns>
        public virtual string GetPageMetaTitle()
        {
            return PageToPresent.Title;
        }

        /// <summary>
        /// Get page meta description
        /// </summary>
        /// <returns></returns>
        public virtual string GetPageMetaDescription()
        {
            return PageToPresent.PageDescription;
        }

        /// <summary>
        /// Gets page H1 header
        /// </summary>
        /// <returns></returns>
        public virtual string GetPageH1()
        {
            return PageToPresent.PageName;
        }
    }
}